﻿
@model IOA.MES.DataAccess.VModel.VViaSiteConfig
@{
    ViewBag.Title = "物料完整性校验";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
    var orderNo = ViewBag.OrderNo as string;
    var workOrderNo = ViewBag.WorkOrderNo as string;
}

<div id="page"></div>

<script type="text/template" id="tplPage">
    <div style="background-color:white;padding:10px;margin:15px">
        <div class="layui-form">
            <div class="layui-form-item" pane="">
                <label class="layui-form-label" style="padding-top: 20px;">{{lang.Field.WhetherToVerify}}：</label>
                <div class="layui-input-inline">
                    <input type="checkbox" id="cbStatus" @(Model.ConfigModel.MaterialInfoControl ? " checked " : "") lay-skin="primary">
                </div>
            </div>
            <div class="layui-form-item" pane="">
                <label class="layui-form-label" style="width:100%;text-align:left;color:#FF5722;">{{lang.Field.DistributeRemark}}</label>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn " lay-submit lay-filter="submit">{{lang.Field.Submit}}</button>
                </div>
            </div>
        </div>
    </div>
</script>

@section Scripts{
    <script>
        var vm = new Vue({
            el: "#page",
            template: "#tplPage",
            data: {
                lang: JSON.parse(lang).package
            }
        });
        var orderNo = "@orderNo",
            workOrderNo = "@workOrderNo";

        setTimeout(function () {
            initLayui();
        }, 50);
        function initLayui() {
            layui.use(['form', 'layer'], function () {
                var layer = layui.layer,
                    form = layui.form;

                form.on('submit(submit)', function (data) {
                    var loadId = layer.load();
                    $.ajax({
                        async: false,
                        url: "/ParaSetting/SaveMaterialInfoControl",
                        data: {
                            model: {
                                OrderNo: orderNo,
                                WorkOrderNo: workOrderNo,
                                ConfigModel: {
                                    MaterialInfoControl: document.getElementById("cbStatus").checked
                                }
                            }
                        },
                        complete: function () {
                            layer.close(loadId);
                        },
                        success: function (res) {
                            if (res.ErrCode != 200) {
                                layer.msg(res.ErrMsg, { icon: 5 });
                                return;
                            }
                            layer.msg("保存成功！", { icon: 6, time: 1500 });
                        }
                    });
                    return false;
                });
            });
        }
    </script>
}
